using System;
using System.Text;
using System.Collections.Generic;
using iBeauty.BusinessObjects;
using iBeauty.DAL;

namespace iBeauty.BLL
{
	public class ProductBLL
	{
		private ProductDAO _ProductDAO;

		public ProductDAO ProductDAO
		{
			get { return _ProductDAO; }
			set { _ProductDAO = value; }
		}

		public ProductBLL()
		{
			ProductDAO = new ProductDAO();
		}
		public List<Product> GetProducts()
		{
			try
			{
				return ProductDAO.GetProducts();
			}
			catch(Exception ex)
			{
				throw ex;
			}
		}
		public Product GetProduct(string ID)
		{
			try
			{
				return ProductDAO.GetProduct(ID);
			}
			catch(Exception ex)
			{
				throw ex;
			}
		}
		public int AddProduct(Product oProduct)
		{
			try
			{
				return ProductDAO.AddProduct(oProduct);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddProduct(string ID,DateTime? CreateDate,DateTime? ModifiedDate,DateTime? TimeStamp,string ProductCode,string ProductName,string GroupId,Single? OriginalPrice,Single? SalePrice,Single? OriginalForeignPrice,Single? SaleForeignPrice,string Currency,string Barcode,string Unit,Single? Capacity,int? AccountId,string Note)
		{
			try
			{
				return ProductDAO.AddProduct(ID,CreateDate,ModifiedDate,TimeStamp,ProductCode,ProductName,GroupId,OriginalPrice,SalePrice,OriginalForeignPrice,SaleForeignPrice,Currency,Barcode,Unit,Capacity,AccountId,Note);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateProduct(Product oProduct)
		{
			try
			{
				return ProductDAO.UpdateProduct(oProduct);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateProduct(string ID,DateTime? CreateDate,DateTime? ModifiedDate,DateTime? TimeStamp,string ProductCode,string ProductName,string GroupId,Single? OriginalPrice,Single? SalePrice,Single? OriginalForeignPrice,Single? SaleForeignPrice,string Currency,string Barcode,string Unit,Single? Capacity,int? AccountId,string Note)
		{
			try
			{
				return ProductDAO.UpdateProduct(ID,CreateDate,ModifiedDate,TimeStamp,ProductCode,ProductName,GroupId,OriginalPrice,SalePrice,OriginalForeignPrice,SaleForeignPrice,Currency,Barcode,Unit,Capacity,AccountId,Note);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveProduct(Product oProduct)
		{
			try
			{
				return ProductDAO.RemoveProduct(oProduct);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveProduct(string ID)
		{
			try
			{
				return ProductDAO.RemoveProduct(ID);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public List<Product> DeserializeProducts(string Path)
		{
			try
			{
				return GenericXmlSerializer<List<Product>>.Deserialize(Path);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public void SerializeProducts(string Path, List<Product> Products)
		{
			try
			{
				GenericXmlSerializer<List<Product>>.Serialize(Products, Path);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
	}
}
